### Alizade, Dancygier, Ditlmann 
### "National Penalties Reversed"
### Replication Code 
### Table A5
### For questions, contact jalizade@princeton.edu

# empty environment
rm(list = ls())


#setwd("")
setwd("C:/Users/Jey/Dropbox/WZB/NaturalizationExperiment/Submission/JOP/replication_JOP/data")


# load necessary packages
library(readstata13)


# load data set
dat <- read.dta13("data_experimental.dta")

# convert treatment variable from second experiment to factor
dat$e2_treat[dat$e2_treat=="NA"] <- NA
dat$e2_treat <- factor(dat$e2_treat, levels=c("Vote Intention (Canadian)", "Control (Turkish)", "Vote Intention (Turkish)", "Integration Problems (Turkish)"))

# relevel treatment variable
dat$e2_treat <- relevel(dat$e2_treat, ref="Integration Problems (Turkish)")

# regression
mod <- glm(e2_response ~ e2_treat*e2_leftpol, dat[dat$e2_treat=="Integration Problems (Turkish)" | dat$e2_treat=="Vote Intention (Turkish)",], family = binomial(link="logit"))
summary(mod)

# log-likelihood
logLik(mod)

### NOTE: We do not provide the data and the code to replicate column 2 of table A6 due to concerns of identifiability of politicians. ###
